package world.criver.mm_vworld_server.function;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 消息处理工具
 * 消息格式
 * mark&value&value&value&...
 */
@Component
public class funClientMessageHandle {
    @Autowired
    private funClientMessageHandleAccount funClientMessageHandleAccount;

    /**
     * 处理客户端发送过来的消息
     * @param id
     * @param message
     */
    public void handle(String id,String message){
        System.out.println("接收："+id+"\t"+message);
        String[] as=message.split("#");
        switch (as[0]){
            case "h"->funClientMessageHandleAccount.heartTest(id);
            case "0"->funClientMessageHandleAccount.existNickname(id,as[1].split("&"));
            case "1"->funClientMessageHandleAccount.registerAccount(id,as[1].split("&"));
            case "2"->funClientMessageHandleAccount.createRole(id,as[1].split("&"));
            case "3"->funClientMessageHandleAccount.testPassword(id, as[1].split("&"));
            case "4"->funClientMessageHandleAccount.getPlayerData(id);
            case "5"->funClientMessageHandleAccount.getDateTime(id);
        }
    }
}
